//
//  InstructionScene.swift
//  mng
//
//  Created by WTFKL on 2018/4/16.
//  Copyright © 2018年 WTF. All rights reserved.
//

import GameplayKit
import SpriteKit

class InstructionScene: SKScene {
    private var backButton : MeCustomButton?;
    override func didMove(to view: SKView) {
        initView();
    }
    func initView(){
        
        backButton = MeCustomButton(btnName: "BackButton", btnSize:CGSize(width: 100, height: 50) , btnCornerRadius: 5);
        backButton?.position = CGPoint(x: 0, y: -160);
        backButton?.m_fontColor = .white;
        backButton?.m_BackgroundColor = .clear;
        backButton?.m_FontName = "GB18030Bitmap";
        backButton?.m_LabelText = "返回";
        backButton?.m_FontSize = 35;
        backButton?.borderColor = .white;
        backButton?.m_borderLineWidth = 1;
        backButton?.clickEvent = {
            let menuScene = SKScene(fileNamed: "MenuScene")!;
//            menuScene.size = CGSize(width: 2048, height: 1536);
//            menuScene.scaleMode = .aspectFill;
            self.view?.presentScene(menuScene,transition: SKTransition.crossFade(withDuration: 0.5));
            print("here-----");
        };
        self.addChild(backButton!);
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        for t in touches {
            let location = t.location(in: self);
            
            let mnode = nodes(at: location);
            
            for nnode in mnode{
                let na = nnode as? MeCustomButton;
                if(na?.name == "BackButton"){
                    backButton?.touchUpInside(highLightBGColor: .white, highLightFontColor: .black);
                }
            }
        }
    }
}
